/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ComposerLot.java
 *
 * Created on 22 juin 2009, 12:24:23
 */

package caylus.GUI;

import caylus.Enum.PhaseDuJeu;
import caylus.Model.Joueur;
import caylus.Model.Lot;

/**
 *
 * @author CeZar
 */
public class ComposerLot extends javax.swing.JDialog {
    private Lot _lot = null;
    private Joueur _joueur;
    private int _deniers = 0;
    private int _bois = 0 ;
    private int _tissu = 0;
    private int _or = 0;
    private int _pierre = 0;
    private int _nourriture = 0;
    private PlateauDuJeu papa ;
    private PhaseDuJeu _phaseDuJeu;

    /** Creates new form ComposerLot */
    public ComposerLot(java.awt.Frame parent, boolean modal, Joueur pJoueur, PhaseDuJeu pPhaseDuJeu) {
        super(parent, modal);
        _joueur = pJoueur ;
        _phaseDuJeu = pPhaseDuJeu;
        papa = (PlateauDuJeu) parent ;
        initComponents();
        jLabelRessourcesPasOk.setVisible(false);
        initJLabelInformationJoueur();
        centrerFenetre();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelComposer = new javax.swing.JPanel();
        jLabelDenierIcon = new javax.swing.JLabel();
        jLabelBoisIcon = new javax.swing.JLabel();
        jLabelTissuIcon = new javax.swing.JLabel();
        jLabelOrIcon = new javax.swing.JLabel();
        jLabelPierreIcon = new javax.swing.JLabel();
        jLabelNourritureIcon = new javax.swing.JLabel();
        jSpinnerBois = new javax.swing.JSpinner();
        jSpinnerTissu = new javax.swing.JSpinner();
        jSpinnerOr = new javax.swing.JSpinner();
        jSpinnerPierre = new javax.swing.JSpinner();
        jSpinnerNourriture = new javax.swing.JSpinner();
        jSpinnerDenier = new javax.swing.JSpinner();
        jPanel1 = new javax.swing.JPanel();
        jLabelOK = new javax.swing.JLabel();
        jLabelRessourcesOk = new javax.swing.JLabel();
        jLabelRessourcesPasOk = new javax.swing.JLabel();
        jLabelInformationJoueur = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Composition d'un Lot");

        jPanelComposer.setBorder(javax.swing.BorderFactory.createTitledBorder("Composer votre Lot"));

        jLabelDenierIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/denier.jpg"))); // NOI18N

        jLabelBoisIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/bois.jpg"))); // NOI18N

        jLabelTissuIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/tissu.jpg"))); // NOI18N

        jLabelOrIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/or.jpg"))); // NOI18N

        jLabelPierreIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/pierre.jpg"))); // NOI18N

        jLabelNourritureIcon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/nourriture.jpg"))); // NOI18N

        jSpinnerBois.setModel(new javax.swing.SpinnerNumberModel(0, 0, 9, 1));
        jSpinnerBois.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSpinnerBoisStateChanged(evt);
            }
        });

        jSpinnerTissu.setModel(new javax.swing.SpinnerNumberModel(0, 0, 7, 1));
        jSpinnerTissu.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSpinnerTissuStateChanged(evt);
            }
        });

        jSpinnerOr.setModel(new javax.swing.SpinnerNumberModel(0, 0, 9, 1));
        jSpinnerOr.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSpinnerOrStateChanged(evt);
            }
        });

        jSpinnerPierre.setModel(new javax.swing.SpinnerNumberModel(0, 0, 9, 1));
        jSpinnerPierre.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSpinnerPierreStateChanged(evt);
            }
        });

        jSpinnerNourriture.setModel(new javax.swing.SpinnerNumberModel(0, 0, 9, 1));
        jSpinnerNourriture.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSpinnerNourritureStateChanged(evt);
            }
        });

        jSpinnerDenier.setModel(new javax.swing.SpinnerNumberModel(0, 0, 9, 1));
        jSpinnerDenier.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSpinnerDenierStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanelComposerLayout = new javax.swing.GroupLayout(jPanelComposer);
        jPanelComposer.setLayout(jPanelComposerLayout);
        jPanelComposerLayout.setHorizontalGroup(
            jPanelComposerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelComposerLayout.createSequentialGroup()
                .addGroup(jPanelComposerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanelComposerLayout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addGroup(jPanelComposerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelComposerLayout.createSequentialGroup()
                                .addComponent(jLabelTissuIcon)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51, Short.MAX_VALUE)
                                .addComponent(jSpinnerTissu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanelComposerLayout.createSequentialGroup()
                                .addComponent(jLabelBoisIcon)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51, Short.MAX_VALUE)
                                .addComponent(jSpinnerBois, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanelComposerLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabelDenierIcon)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 56, Short.MAX_VALUE)
                        .addComponent(jSpinnerDenier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73, Short.MAX_VALUE)
                .addGroup(jPanelComposerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelOrIcon)
                    .addComponent(jLabelNourritureIcon)
                    .addComponent(jLabelPierreIcon))
                .addGap(45, 45, 45)
                .addGroup(jPanelComposerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSpinnerNourriture, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jSpinnerOr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jSpinnerPierre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(68, 68, 68))
        );
        jPanelComposerLayout.setVerticalGroup(
            jPanelComposerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelComposerLayout.createSequentialGroup()
                .addGroup(jPanelComposerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelComposerLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelComposerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabelDenierIcon)
                            .addComponent(jSpinnerDenier, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanelComposerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSpinnerBois, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelBoisIcon)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelComposerLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelComposerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSpinnerOr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelOrIcon))
                        .addGap(26, 26, 26)))
                .addGap(18, 18, 18)
                .addGroup(jPanelComposerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelTissuIcon)
                    .addComponent(jLabelNourritureIcon)
                    .addComponent(jSpinnerTissu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jSpinnerNourriture, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(21, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelComposerLayout.createSequentialGroup()
                .addContainerGap(66, Short.MAX_VALUE)
                .addComponent(jLabelPierreIcon)
                .addGap(52, 52, 52))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelComposerLayout.createSequentialGroup()
                .addContainerGap(66, Short.MAX_VALUE)
                .addComponent(jSpinnerPierre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(52, 52, 52))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Valider votre Lot"));

        jLabelOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/caylus_button_ok.png"))); // NOI18N
        jLabelOK.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelOKMouseClicked(evt);
            }
        });

        jLabelRessourcesOk.setForeground(new java.awt.Color(0, 153, 51));
        jLabelRessourcesOk.setText("Vous avez assez de ressources pour composer ce lot.");

        jLabelRessourcesPasOk.setForeground(new java.awt.Color(204, 0, 0));
        jLabelRessourcesPasOk.setText("Vous n'avez pas assez de ressources pour ce lot!");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabelRessourcesOk)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabelRessourcesPasOk)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addComponent(jLabelOK)
                .addGap(24, 24, 24))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelOK)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(jLabelRessourcesOk)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelRessourcesPasOk)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabelInformationJoueur.setText("Cootcha...");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanelComposer, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(jLabelInformationJoueur)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(22, Short.MAX_VALUE)
                .addComponent(jLabelInformationJoueur)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanelComposer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jLabelOKMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelOKMouseClicked
        if(jLabelOK.isEnabled()){
            if (controleRessources()) {
                _lot = new Lot(_deniers, _bois, _tissu, _or, _pierre, _nourriture);
                papa.lot = _lot ;
                this.dispose();
            }
        }
    }//GEN-LAST:event_jLabelOKMouseClicked

    private void jSpinnerBoisStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinnerBoisStateChanged
         _bois = (Integer) jSpinnerBois.getModel().getValue();
        if(_bois > _joueur.getRessouces().getBois()) {
            jSpinnerBois.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));
            jLabelOK.setEnabled(false);
            jLabelRessourcesOk.setVisible(false);
            jLabelRessourcesPasOk.setVisible(true);
        }   else{
            jLabelOK.setEnabled(true);
            jLabelRessourcesOk.setVisible(true);
            jLabelRessourcesPasOk.setVisible(false);
        }
    }//GEN-LAST:event_jSpinnerBoisStateChanged

    private void jSpinnerDenierStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinnerDenierStateChanged
         _deniers = (Integer) jSpinnerDenier.getModel().getValue();
         if(_deniers > _joueur.getRessouces().getDeniers()){
            jSpinnerDenier.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));
            jLabelOK.setEnabled(false);
            jLabelRessourcesOk.setVisible(false);
            jLabelRessourcesPasOk.setVisible(true);
        }   else{
            jLabelOK.setEnabled(true);
            jLabelRessourcesOk.setVisible(true);
            jLabelRessourcesPasOk.setVisible(false);
        }
    }//GEN-LAST:event_jSpinnerDenierStateChanged

    private void jSpinnerTissuStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinnerTissuStateChanged
         _tissu = (Integer) jSpinnerTissu.getModel().getValue();
        if(_tissu > _joueur.getRessouces().getTissu()){
            jSpinnerTissu.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));
            jLabelOK.setEnabled(false);
            jLabelRessourcesOk.setVisible(false);
            jLabelRessourcesPasOk.setVisible(true);
        }   else{
            jLabelOK.setEnabled(true);
            jLabelRessourcesOk.setVisible(true);
            jLabelRessourcesPasOk.setVisible(false);
        }
    }//GEN-LAST:event_jSpinnerTissuStateChanged

    private void jSpinnerOrStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinnerOrStateChanged
         _or = (Integer) jSpinnerOr.getModel().getValue();
         if(_or > _joueur.getRessouces().getOr()){
             jSpinnerOr.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));
             jLabelOK.setEnabled(false);
             jLabelRessourcesOk.setVisible(false);
             jLabelRessourcesPasOk.setVisible(true);
        }   else{
            jLabelOK.setEnabled(true);
            jLabelRessourcesOk.setVisible(true);
            jLabelRessourcesPasOk.setVisible(false);
        }
    }//GEN-LAST:event_jSpinnerOrStateChanged

    private void jSpinnerPierreStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinnerPierreStateChanged
         _pierre = (Integer) jSpinnerPierre.getModel().getValue();
         if(_pierre > _joueur.getRessouces().getPierre()) {
             jSpinnerPierre.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));
             jLabelOK.setEnabled(false);
             jLabelRessourcesOk.setVisible(false);
             jLabelRessourcesPasOk.setVisible(true);
        }   else{
            jLabelOK.setEnabled(true);
            jLabelRessourcesOk.setVisible(true);
            jLabelRessourcesPasOk.setVisible(false);
        }
    }//GEN-LAST:event_jSpinnerPierreStateChanged

    private void jSpinnerNourritureStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinnerNourritureStateChanged
        _nourriture = (Integer) jSpinnerNourriture.getModel().getValue();
         if(_nourriture > _joueur.getRessouces().getNouriture()) {
             jSpinnerNourriture.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));
             jLabelOK.setEnabled(false);
             jLabelRessourcesOk.setVisible(false);
             jLabelRessourcesPasOk.setVisible(true);
        }   else{
            jLabelOK.setEnabled(true);
            jLabelRessourcesOk.setVisible(true);
            jLabelRessourcesPasOk.setVisible(false);
        }
    }//GEN-LAST:event_jSpinnerNourritureStateChanged

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabelBoisIcon;
    private javax.swing.JLabel jLabelDenierIcon;
    private javax.swing.JLabel jLabelInformationJoueur;
    private javax.swing.JLabel jLabelNourritureIcon;
    private javax.swing.JLabel jLabelOK;
    private javax.swing.JLabel jLabelOrIcon;
    private javax.swing.JLabel jLabelPierreIcon;
    private javax.swing.JLabel jLabelRessourcesOk;
    private javax.swing.JLabel jLabelRessourcesPasOk;
    private javax.swing.JLabel jLabelTissuIcon;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanelComposer;
    private javax.swing.JSpinner jSpinnerBois;
    private javax.swing.JSpinner jSpinnerDenier;
    private javax.swing.JSpinner jSpinnerNourriture;
    private javax.swing.JSpinner jSpinnerOr;
    private javax.swing.JSpinner jSpinnerPierre;
    private javax.swing.JSpinner jSpinnerTissu;
    // End of variables declaration//GEN-END:variables

    public boolean controleRessources(){
        if(_deniers > _joueur.getRessouces().getDeniers()) jSpinnerDenier.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));
        if(_bois > _joueur.getRessouces().getBois()) jSpinnerBois.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));
        if(_or > _joueur.getRessouces().getOr()) jSpinnerOr.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));
        if(_pierre > _joueur.getRessouces().getPierre()) jSpinnerPierre.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));
        if(_nourriture > _joueur.getRessouces().getNouriture()) jSpinnerNourriture.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));
        if(_tissu > _joueur.getRessouces().getTissu()) jSpinnerTissu.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 0, 0), 1, true));

            if( (_deniers > _joueur.getRessouces().getDeniers())
             || (_bois > _joueur.getRessouces().getBois())
             || (_or > _joueur.getRessouces().getOr())
             ||(_pierre > _joueur.getRessouces().getPierre())
             || (_nourriture > _joueur.getRessouces().getNouriture()) ){
                jLabelRessourcesPasOk.setVisible(true);
                jLabelRessourcesOk.setVisible(false);
                return false;
            }
        else return true;

    }

    public Joueur get_joueur() {
        return _joueur;
    }

    public void set_joueur(Joueur _joueur) {
        this._joueur = _joueur;
    }

    public void initJLabelInformationJoueur(){
        switch(_phaseDuJeu){
            case ACTIVATION_BATIMENTS:
                jLabelInformationJoueur.setText(_joueur.getNom() + ": Vous devez composer un lot pour construire ce batiment.");
                break;
            case CONSTRUCTION_CHATEAU:
                jLabelInformationJoueur.setText(_joueur.getNom() + ": Vous devez composer un lot pour construire dans le château.");
                break;
            default:
                break;
        }
    }
    public void centrerFenetre(){
            java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
            pack();
            setLocation(
                        (screenSize.width-this.getWidth())/2,
                        (screenSize.height-this.getHeight())/2
                       );
    }
    
}

